<?php
include_once('conn.php');
include_once('settings.php');

if(!isset($_REQUEST['id']) || intval($_REQUEST['id']) < 1)
{
	header("Location:404.html");
	exit();
}
$id = $_REQUEST['id'];
//increase hits number
increase_article_hits_number($id);

$query = sprintf("SELECT * FROM `news` WHERE `id`=%d",$id);
$result=mysql_query($query);
if($result == false)
	exit(sprintf("%s%s%s",mysql_error(),__FILE__,__LINE__));
	
$info = mysql_fetch_assoc($result);

if($info == false || $info['isok'] != '1')
{
	header("Location:404.html");
	exit();
}
	
//fetch pages
$query = sprintf("SELECT `content` FROM `news2` WHERE `newsid`=%d",$info['id']);
$result=mysql_query($query);
if($result == false)
	exit(sprintf("%s%s%s",mysql_error(),__FILE__,__LINE__));
$page_list = array();
while(($row = mysql_fetch_assoc($result)))
{
	$page_list[] = $row;
}



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> [ BIOS Monthly ] <?php echo html_safe($info['title']);?> </title>
<meta name="description" content="<?php echo utf8substr(strip_tags($info['content']),0,150);?>" />
<?php
	$meta_keywords = '';
	if(strlen($info['tagcloud']) > 0)
		$meta_keywords .= $info['tagcloud'].',';
	if(strlen($info['tagcloud1']) > 0)
		$meta_keywords .= $info['tagcloud1'].',';
	if(strlen($info['tagcloud2']) > 0)
		$meta_keywords .= $info['tagcloud3'].',';
	if(strlen($info['tagcloud3']) > 0)
		$meta_keywords .= $info['tagcloud3'].',';
	if(strlen($info['tagcloud4']) > 0)
		$meta_keywords .= $info['tagcloud4'].',';
	if(strlen($info['tagcloud5']) > 0)
		$meta_keywords .= $info['tagcloud5'].',';
	if(strlen($meta_keywords) > 0)
		$meta_keywords = substr($meta_keywords,0,-1);
?>
<meta name="KEYWORDS" CONTENT="<?php echo $meta_keywords;?>" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link href="css/slide-page.css" rel="stylesheet" type="text/css" />
<?php 
$page_css = get_article_page_css_file_by_catalog($info['BigClassName']);
?>
<link href="css/<?php echo $page_css;?>" rel="stylesheet" type="text/css" />
<?php 
$page_style_css = get_article_page_style_css_file_by_catalog($info['BigClassName']);
?>
<link href="css/<?php echo $page_style_css;?>" rel="stylesheet" type="text/css" />
<script src="js/jquery-latest.js" type="text/javascript"></script>
<script src="js/jquery.bxSlider.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/image.gallery2.js"></script>
<script type="text/javascript">
  $(function(){
  	page_transition.init({left:'0'});
      //   $(window).trigger('resize');
  });
</script>
<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
<script type="text/javascript">
$(document).ready(function(){
	$('#contacte').show();
    $('#slider1').bxSlider({
        infiniteLoop: true,
        hideControlOnEnd: true,
        pager: true,
        pagerSelector: null,
		speed: 700,
        pagerType: 'full',
        pagerLocation: 'bottom'
    });
});
</script>

	<script type="text/javascript">
	$(document).ready(function(){
		$(".hoverFeature ,.hoverColumn,.hoverNews,.hoverEvent , .hoverRss").css("opacity","0");
		$(".hoverFeature ,.hoverColumn,.hoverNews,.hoverEvent , .hoverRss").hover(function () {
			$(this).stop().animate({
				opacity: 1
			}, "fast");
		},
		function () {
			$(this).stop().animate({
				opacity: 0
			}, "fast");
		});
		});
	</script>
	
</head>
<body>
<div id="all"><!-- start #all //-->
<div id="main" class="clearfix"><!-- start #main //-->
<?php include_once('top-main.php');?>

<div id="contacte" class="clearfix" style="display:none;"><!-- start #contacte //-->
<div id="contacte-top" style="position: relative;" class="sarea"><!-- start #contacte-top //-->
	
	<?php for($i=1;$i<7;$i++):?>
   <?php if(strlen($info["images$i"]) > 0):?>
	<div style="left: 0pt; top: 0pt; position: absolute;width:914px;" class="rotator r1">
			<img src="upfiles/<?php echo html_safe($info["images$i"]);?>"  height="400">
	</div>
	<?php endif;?>
  <?php endfor;?>
</div><!-- end #contacte-top //-->

<script language="javascript" src="js/rAlert.js"></script>
<script language="javascript">
function mail_to(id) {
		rAlert("mail.php?title=<?php echo urlencode(html_safe($info["title"]));?>&url=<?php echo urlencode(sprintf("contacta.php?id=%d",$_REQUEST['id']));?>" , null, "文章轉寄", 620, 380);
}
function addFacebook() {
 
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(window.location.href)+'&t='+encodeURIComponent('<?php echo html_safe($info['title']);?>'),'_blank');
}
</script>
<div id="contacte-con" class="clearfix"><!-- start #contacte-con //-->
<div id="contacte-con-line">
  <div id="contacte-con-1">
    <ul  class="navicontroller">
    	<?php for($i=1;$i<7;$i++):?>
    	<?php if(strlen($info["images$i"]) > 0):?>
    	<li><a href="#"><img src="upfiles/<?php echo html_safe($info["images$i"]);?>-35x35.jpg" width="35" height="35" /></a></li>
    	<?php endif;?>
    	<?php endfor;?>
    </ul>
  </div>
  <div id="contacte-con-2"> 
  <ul>
<li>
  <iframe src="http://www.facebook.com/plugins/like.php?app_id=217457261619168&amp;href=www.biosmonthly.com/<?php echo urlencode(sprintf("contacta.php?id=%d",$_REQUEST['id']));?>&amp;send=false&amp;layout=button_count&amp;width=90&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe>
</li>

      <li><a href="#" onclick="javascript:addFacebook();return false;"><img src="images/btn-facebook2.png" width="17" height="16" /></a></li>
  <li><a href="#" onclick="javascript:mail_to(<?php printf("%d",$info["id"]);?>);return false;"><img src="images/btn-mail2.png" width="25" height="17" /></a></li>
  
   
    </ul>
    </div>
    </div>
    <div id="contacte-con-page-title"><h3><?php echo html_safe($info['title']);?></h3></div>
 <div id="wrapper" >
  <ul id="slider1" style="width: 999999px; height:256px; position: relative; left: -2400px;height:auto;">
   
    <li style="width:600px; height:400px;  float: left; listbx-next-style: none outside none;">
         <?php echo stripslashes($info['content']);?>
    </li>
    <?php $lastindex = count($page_list) - 1;?>
    <?php foreach($page_list as $index=>$pageContent):?>
    	<li style="width:600px; height:400px; float: left; list-style: none outside none;" <?php if($index < $lastindex){ ?>class="pager"<?php }?>>
    		<?php echo stripslashes($pageContent['content'])?>
		 </li>
    <?php endforeach;?>
    
</ul>
    </div>
    
</div><!-- end #contacte-con //-->
	


</div><!-- end #contactc //-->

  <?php $extra_read_list = get_article_extra_read($info['id']);?>
	<?php include_once('block_extra_read.php');?>
  

</div><!-- end #main //-->
</div><!-- end #all //-->

<?php include_once('down.php');?>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-22189695-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</body>
</html>